<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="gly"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<html>
<head>
<meta charset="GB18030">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/css/font-awesome.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/css/main.css">

</head>
<body style="margin-top: -50px">
	<div class="panel panel-default" style="margin-top: 0px">
		<div class="panel-heading">
			<h3 class="panel-title">
				<i class="glyphicon glyphicon-th"></i> 年检记录
			</h3>
		</div>
		<div class="panel-body">
			<form class="form-inline" role="form" style="float: left;" method="post" action="${pageContext.request.contextPath}/daily/getByCondition">

				<div class="form-group has-feedback">
					<div class="input-group">
						<div class="input-group-addon">车牌号码</div>
						<input class="form-control has-success" type="text"
							placeholder="请输入车牌号码，支持模糊查询" id="111condition" name="condition" value="${sessionScope.condition}"/> 
					</div>
				</div>
				<button type="submit" class="btn btn-warning" id="search_btn">
					<i class="glyphicon glyphicon-search"></i> 查询
				</button>
			</form>

			<form action="${pageContext.request.contextPath}/daily/delete2" method="post">
			  
			<button class="btn btn-danger" type="submit" 
				style="float: right; margin-left: 10px;" id="delChecks_btn" >
				<i class=" glyphicon glyphicon-remove"></i> 批量删除
			</button>
			<a class="btn btn-primary" style="float: right; margin-left: 10px;"
				href="${pageContext.request.contextPath}/daily/add"><span
				class="glyphicon glyphicon-plus"></span>增加</a> <br>
			<br>
			<hr style="clear: both;">
			<div class="table-responsive">
				<table class="table  table-bordered">
					<thead>
						<tr>
							<th width="30"><input type="checkbox" id="selectAll"></th>
							<th>车牌号码</th>
							<th>年间标号</th>
							<th>年检日期</th>
							<th>年检金额</th>
							<th>年检单位</th>
							<th>下次年检日期</th>
							<th>经办人</th>
							<th>备注</th>
							<th width="125">操作</th>
						</tr>
					</thead>
					<!-- 信息展示 -->
					<tbody id="tb1">
						<gly:forEach items="${pageInfo.list}" var="check">
	            			<tr class="info">
	            				<td style="text-align: center;">
	            					<div class="checkbox">
										<label>
											<input type="checkbox" name="checkId" value="${check.crId}">
										</label>
								</div>
	            				</td>	 
	            				<td>${check.crCarlicense}</td>
								<td>${check.crNum}</td>
								<td><fmt:formatDate value="${check.crDate}" pattern="yyyy-MM-dd"/></td>
								<td>${check.crAmount}</td>
								<td>${check.crUnit}</td>
								<td><fmt:formatDate value="${check.crNextdate}" pattern="yyyy-MM-dd"/></td>
								<td>${check.crDriver}</td>
								<td>${check.crRemark}</td>
	      	
	            				<td>
	            					<button type="button" class="btn btn-success btn-xs"
									onclick="window.location.href='${pageContext.request.contextPath}/daily/showInfo?cid='+${check.crId}">
										<i class=" glyphicon glyphicon-list-alt"></i>
									</button>
									<button type="button" class="btn btn-primary btn-xs" onclick="window.location.href='${pageContext.request.contextPath}/daily/update1?crid='+${check.crId}">
										<i class=" glyphicon glyphicon-pencil"></i>
									</button>
									<button type="button" class="btn btn-danger btn-xs" id="sub1"
										onclick="window.location.href='${pageContext.request.contextPath}/daily/delete?cid='+${check.crId}">
										<i class=" glyphicon glyphicon-remove"></i>
									</button>
	            				</td>
	            			</tr>
	            		</gly:forEach>
	            		
					</tbody>
					<div class="row">
				<!--文字信息-->

				<div align="center">
					<ul class="pagination">

						<li><a href="${pageContext.request.contextPath}/driver/getByCondition?dr_pn=1">首页</a></li>

						<!--上一页-->
						<li><gly:if test="${pageInfo.hasPreviousPage}">
								<a
									href="${pageContext.request.contextPath}/driver/getByCondition?dr_pn=${pageInfo.pageNum-1}"
									aria-label="Previous"> <span aria-hidden="true">«</span>
								</a>
							</gly:if></li>

						<!--循环遍历连续显示的页面，若是当前页就高亮显示，并且没有链接-->
						<gly:forEach items="${pageInfo.navigatepageNums}" var="page_num">
							<gly:if test="${page_num == pageInfo.pageNum}">
								<li class="active"><a href="#">${page_num}</a></li>
							</gly:if>
							<gly:if test="${page_num != pageInfo.pageNum}">
								<li><a
									href="${pageContext.request.contextPath}/driver/getByCondition?dr_pn=${page_num}">${page_num}</a></li>
							</gly:if>
						</gly:forEach>

						<!--下一页-->
						<li><gly:if test="${pageInfo.hasNextPage}">
								<a
									href="${pageContext.request.contextPath}/driver/getByCondition?dr_pn=${pageInfo.pageNum+1}"
									aria-label="Next"> <span aria-hidden="true">»</span>
								</a>
							</gly:if></li>

						<li><a
							href="${pageContext.request.contextPath}/driver/getByCondition?dr_pn=${pageInfo.pages}">尾页</a></li>
					</ul>
				</div>
				<div align="center">当前第 ${pageInfo.pageNum} 页.总共
					${pageInfo.pages} 页.一共 ${pageInfo.total} 条记录</div>
			</div>

					<tfoot>
							     <tr >
								     <td colspan="12" align="center">
										<ul class="pagination">
												<li class="disabled"><a href="#">上一页</a></li>
												<li class="active"><a href="#">1 <span class="sr-only">(current)</span></a></li>
												<li><a href="#">2</a></li>
												<li><a href="#">3</a></li>
												<li><a href="#">4</a></li>
												<li><a href="#">5</a></li>
												<li><a href="#">下一页</a></li>
											 </ul>
									 </td>
								 </tr>
	
				  			</tfoot>
				</table>
			</div>
			</form>
			<!-- 分页信息 -->
			<div class="row" id="page_div"></div>
		</div>

		<script
			src="${pageContext.request.contextPath}/static/jquery/jquery-2.1.1.min.js"></script>
		<script
			src="${pageContext.request.contextPath}/static/bootstrap/js/bootstrap.min.js"></script>
		<script
			src="${pageContext.request.contextPath}/static/script/docs.min.js"></script>

		<script type="text/javascript">
		$(function(){
			var deleterows='${deleterows}';
			if (deleterows!="") {
				alert("成功删除"+deleterows+"条记录");
			}
			$("#selectAll").change(function(){
				if($(this).prop('checked')==true){
					$('input[name="checkId"]').each(function(){
					$(this).prop('checked',true);
				})
				}else{
					$('input[name="checkId"]').each(function(){
						$(this).prop('checked',false);
					})
				}
				
			});
			$("#sub1").click(function(){
				var flag=false;
				$('input[name="checkId"]').each(function(){
					if($(this).prop('checked')==true){
						flag=true;
					}
				})
				if (flag==false) {
					alert("请选择删除项目！");
				return false;
				}
				if (confirm("是否删除选中记录?")==false) {
					return false;
				}
			})
		})

		</script>
</body>
</html>